package cn.zyjblogs.netty.groupchat;

import javafx.util.Builder;

/**
 *
 */
public class User {
    private Integer id;
    private String pwd;

    public User() {
    }
     public User(Integer id, String pwd) {
        this.id = id;
        this.pwd = pwd;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", pwd='" + pwd + '\'' +
                '}';
    }

    public static UserBuilder builder() {
        return new UserBuilder();
    }
    public  User(UserBuilder builder) {
        this.id = builder.id;
        this.pwd = builder.pwd;
    }

    public static class UserBuilder implements Builder<User> {
        private Integer id;
        private String pwd;

        public UserBuilder id(Integer id) {
            this.id = id;
            return this;
        }

        public UserBuilder pwd(String pwd) {
            this.pwd = pwd;
            return this;
        }

        @Override
        public User build() {
            return new User(this);
        }
    }

    public static void main(String[] args) {
        User build = User.builder().id(1231).pwd("3131").build();
        System.out.println(build.toString());
    }
}
